package kuangxiaoyang.hnevc.com.shijiebei;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;

import java.util.List;

import kuangxiaoyang.hnevc.com.shijiebei.adapter.MyAdatper1;

/**
 * Created by Administrator on 2020/12/31.
 */

public class ShouYeActivity extends AppCompatActivity {
    List<ShiJieBei.ResultBean> shijiebeilist;
    private ListView listView;
    private TextView textView;
    private ShiJieBei shijiebei;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shouye);
        initView();
        initData();
        initEvent();
    }

    private void initView() {
        listView = (ListView) findViewById(R.id.listview1);
        textView = (TextView) findViewById(R.id.qdph_tv);

    }

    private void initData() {
        Gson gson = new Gson();
        String jsonData = new GetJsonDataUtil().getJson(ShouYeActivity.this, "shijiebei.json");
        shijiebei = gson.fromJson(jsonData, ShiJieBei.class);
        shijiebeilist = shijiebei.getResult();
        listView.setAdapter(new MyAdatper1(ShouYeActivity.this, shijiebeilist));

    }

    private void initEvent() {

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(ShouYeActivity.this, LiBiaoActivity.class);
                startActivity(intent);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        Intent intent = new Intent(ShouYeActivity.this, LiBiaoActivity.class);
                        Bundle bundle = new Bundle();
                        bundle.putString("id", shijiebeilist.get(position).getId());
                        bundle.putInt("sheng", shijiebeilist.get(position).getSheng());
                        bundle.putInt("fu", shijiebeilist.get(position).getFu());
                        bundle.putInt("ping", shijiebeilist.get(position).getPing());
                        bundle.putInt("wingoal", shijiebeilist.get(position).getWingoal());
                        bundle.putInt("losegoal", shijiebeilist.get(position).getTotalgoal());
                        bundle.putInt("score", shijiebeilist.get(position).getScore());
                        bundle.putString("detail", shijiebeilist.get(position).getDetail());
                        bundle.putString("path", shijiebeilist.get(position).getUrl());
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }
                });
            }
        });
    }
}





















